import urllib.request

url = "http://www.baidu.com"
response = urllib.request.urlopen(url)

# 一个类型和六个方法
# print(type(response)) # <class 'http.client.HTTPResponse'>

# 按照字节一个一个去读
# content = response.read()

# 返回多少个字节
# content = response.read(5)
# print(content)
# 读取一行
# content = response.readline()
# print(content)
# content = response.readlines()
# print(content)

# 返回状态码
print(response.getcode())
print(response.geturl())
print(response.getheaders()) # 获取一些状态信息